package ljl.alg.jianzhioffer.round3.medium;

import java.util.Arrays;
import java.util.stream.IntStream;

public class _45_minNumber {

    public String minNumber(int[] nums) {
        String[] strings = IntStream.of(nums).mapToObj(String::valueOf).toArray(String[]::new);
        Arrays.sort(strings, (x, y) -> (x + y).compareTo(y + x));
        StringBuilder res = new StringBuilder(strings.length);
        for (String string : strings) {
            res.append(string);
        }
        return res.toString();
    }
}
